
capture log close

set more off
set matsize 10000

use rep_final, clear

	*noncitizens
	keep if cit==0
	*married last year, currently still married with spouse present
	keep if marrinyr==2 & married==1 
	*spouse info is avail.
	drop if citizen_sp==.

* Define control variables 

	local demog "age age2 male yreduc i.racegr"	
	local imm "ysm i.bpl " 
	local fe "i.statefip i.yrmarr "
		
	local full "`demog' `imm' `fe' "
	
* Use yrmarr to measure time treatment because individuals are surveyed throughout the year

	g post1=(yrmarr>=2013 & yrmarr<=2016)
	g post2=(yrmarr>=2017)
	
	g treatpost1=treatgr*post1
	g treatpost2=treatgr*post2
	
	
*************************************************************************
*Table 6 - Panel A
	*by arrival age - differentiate very young arrivals vs. teen arrivals
		*Use age 12 as cutoff as that is when language attainment starts to slow.
	
	g youngarr=((age-(year-yrimmig))<13)
	
	local a=1
	forval i=0/1 {
	
		foreach controlgr of varlist controlgrdaca {

		foreach depvar of varlist cit_sp  {
	
			
			display ""
			display "--------------------------------------"
			
			display "Dependent Variable: `depvar' "
			display "Contorl Group: `controlgr' "
			display "Childimm `i'"
			
			display "--------------------------------------"
			

			*treatpost1 and treatpost2 both compare to pre-period.

			
			reg `depvar' treatpost1 treatpost2 treatgr `full'  if (daca==1|`controlgr'==1) & youngarr==`i'   [pweight = perwt] , cluster(statefip)
			est sto e`a'
			
			
			local a=`a'+1
			
		*dep var mean
	
		sum cit_sp [fweight=perwt] if e(sample) 
				}

			}

		}			
		
		*make table
			esttab e1 e2  ///
					using table6_panelA.csv, se  ///
					mtitles("Arrived after 12" "Arrived at or before 12") ///
					title(Intermarriage Rate) ///
					b(%9.4f) se(%9.4f) star(* 0.1 ** 0.05 *** 0.01) ///
					nogaps replace			

					
********************************************************************************
*Table 6 - Panel B

	*by young marriage age
	
	g youngmarr=(age<=22)
	
	
	*alternative young marriage age
	*g youngmarr=(age<=20)

	*alternative young marriage: both spouse young
	*g youngmarr=(age<=22 & age_sp<=22)
	
	local a=1
	forval i=0/1 {
	
		foreach controlgr of varlist controlgrdaca {

		foreach depvar of varlist cit_sp {
	
			
			display ""
			display "--------------------------------------"
			
			display "Dependent Variable: `depvar' "
			display "Contorl Group: `controlgr' "
			display "Childimm `i'"
			
			display "--------------------------------------"
			

			*treatpost1 and treatpost2 both compare to pre-period.

			
			reg `depvar' treatpost1 treatpost2 treatgr `full'  ///
				if (daca==1|`controlgr'==1) & youngmarr==`i'   ///
				[pweight = perwt] , cluster(statefip)
			est sto e`a'
			
			local a=`a'+1
			
		*dep var mean
	
		sum cit_sp [fweight=perwt] if e(sample) 
				}

			}

		}			
		
		*make table
			esttab e1 e2 ///
					using table6_panelB.csv, se  ///
					mtitles("Married after 22"  "Married at or before 22") ///
					title(Intermarriage Rate) ///
					b(%9.4f) se(%9.4f) star(* 0.1 ** 0.05 *** 0.01) ///
					nogaps replace				
	
	
	
**************************************************************************
*Table 6 - Panel C
	
	*by continent - access to U.S. via land
		*Include north America, central America, Caribbean, and South America
	
	g landaccess=(bpl>=150 & bpl<=300)
	
	local a=1
	forval i=0/1 {
	
		foreach controlgr of varlist controlgrdaca  {

		foreach depvar of varlist cit_sp {
	
			
			display ""
			display "--------------------------------------"
			
			display "Dependent Variable: `depvar' "
			display "Contorl Group: `controlgr' "
			display "Childimm `i'"
	
			display "--------------------------------------"
			

			*treatpost1 and treatpost2 both compare to pre-period.

			
			reg `depvar' treatpost1 treatpost2 treatgr `full'  ///
				if (daca==1|`controlgr'==1) & landaccess==`i'   ///
				[pweight = perwt] , cluster(statefip)
			est sto e`a'	

			local a=`a'+1
			
		*dep var mean
	
		sum cit_sp [fweight=perwt] if e(sample) 
				}

			}

		}			
		
		*make table
			esttab e1 e2 ///
					using table6_panelC.csv, se  ///
					mtitles("Other Continents" ///
							"American Continent" ) ///
					title(Intermarriage Rate) ///
					b(%9.4f) se(%9.4f) star(* 0.1 ** 0.05 *** 0.01) ///
					nogaps replace				
	
		

